import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import Antd from 'ant-design-vue';
import { message } from 'ant-design-vue'
import VueI18n from 'vue-i18n'
import axios from 'axios'
import 'ant-design-vue/dist/antd.less';
import './router/RouteinTerceptor'
import VueBarcode from "vue-barcode";
import htmlToPdf from '@/utils/htmlToPdf'
import Print from 'vue-print-nb'
import '@/utils/directives.js'
import '@/assets/iconfont/iconfont.css'
import { scrollBoard, scrollRankingBoard } from '@jiaminghi/data-view'
Vue.use(scrollBoard)
Vue.use(scrollRankingBoard)
Vue.use(Print); //注册
Vue.use(htmlToPdf)

axios.defaults.withCredentials = true;
axios.defaults.crossDomain = true;
Vue.component('barcode', VueBarcode);
//注入使用
Vue.use(Antd);
Vue.use(message)
Vue.use(VueI18n);
// 挂载全局信息提示
Vue.prototype.$message = message
//挂载中介
const bus = new Vue();
Vue.prototype.$bus = bus;
const i18n = new VueI18n({
  locale: 'zn',
  messages: {
    'zn': require('./i18n/langs/zn'),
    'en': require('./i18n/langs/en')
  }
});

Vue.prototype.resetSetItem = function (key, newVal) {
  if (key === 'data') {
    // 创建一个StorageEvent事件
    var newStorageEvent = document.createEvent('StorageEvent');
    const storage = {
      setItem: function (k, val) {
        sessionStorage.setItem(k, val);
        // 初始化创建的事件
        newStorageEvent.initStorageEvent('setItem', false, false, k, null, val, null, null);
        // 派发对象
        window.dispatchEvent(newStorageEvent)
      }
    }
    return storage.setItem(key, newVal);
  }
}

Vue.config.productionTip = false
new Vue({
  router,
  store,
  i18n,
  render: h => h(App)
}).$mount('#app')
